package android.pot.com.smartcar.util;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by zhaoshilu on 2018/5/4.
 */
public class URLAnalysis{
    private Map<String, String> paramMap = new HashMap<String, String>();

    public void analysis(String url) {
        paramMap.clear();
        if (!"".equals(url)) {// 如果URL不是空字符串
            url = url.substring(url.indexOf('?') + 1);
            String paramaters[] = url.split("&");
            for (String param : paramaters) {
                String value_1 = "";
                String value_2 = "";
                String values[] = param.split("=");
                if (values.length>0){
                    value_1 = values[0];
                }
                if (values.length>1){
                    value_2 = values[1];
                }
                paramMap.put(value_1, value_2);
            }
        }
    }

    public String getParam(String name) {
        return paramMap.get(name);
    }
}